package com.heima.wemedia.fegin;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.heima.apis.wemedia.IWemediaClient;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmUser;
import com.heima.wemedia.service.WmChannelService;
import com.heima.wemedia.service.WmUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class WemediaClient implements IWemediaClient {

    @Autowired
    private WmChannelService wmChannelService;

    @Autowired
    private WmUserService wmUserService;

    @GetMapping("/api/v1/channel/list")
    @Override
    public ResponseResult getChannels() {
        return ResponseResult.okResult(wmChannelService.list());
    }

<<<<<<< HEAD
    @Override
    @PostMapping("api/v1/wemedia/user/{id}")
    public WmUser getWmUser(@PathVariable("id") Integer id) {

        LambdaQueryWrapper<WmUser> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(WmUser::getApUserId,id);

        WmUser wmUser = wmUserService.getOne(queryWrapper);

        return wmUser;
    }

    @Override
    @PostMapping("api/v1/wemedia/user/update")
    public void update(@RequestBody WmUser wmUser) {
        wmUserService.updateById(wmUser);
    }

    @Override
    @PostMapping("api/v1/wemedia/user/save")
    public void save(@RequestBody WmUser wmUser) {
        wmUserService.save(wmUser);
    }
=======


>>>>>>> dev/channel
}